<?php
include_once(dirname(__FILE__)."/../inc/common.php");

$accountClass = new tally_account();
$accountList = $accountClass->findAccountList($userId);

$flowTypeClass = new tally_flowType();
$expenseFlowTypeList = $flowTypeClass->findFlowTypeByInout($userId, tally_flow::$INOUT_EXPENSE);

?>
<div class="box">
	<div class="head">
		<ul><li>记账</li></ul>
	</div>
	<div class="body tally_nav">
		<div class="tally_btn">
			<img src="../images/tally_btn.gif"/>
			<div id="quick_menu" class="tally_menu" style="width: 480px;">

				<div class="list_box">
					<ul>
						<li>
							<span><img src="../images/icons/income.gif" align="absmiddle"><a href="javascript:fGoto();" onclick="Income.goAdd('11','');CM.afterSubmit=Flow.listByAccount;CM.afterSubmit0=Tally.loadBoard;">收入</a></span>
							<span>|</span>
							<span><img src="../images/icons/expense.gif" align="absmiddle"><a href="javascript:fGoto();" onclick="Expense.goAdd('20','');CM.afterSubmit=Flow.listByAccount;CM.afterSubmit0=Tally.loadBoard;">支出</a></span>
							<span>|</span>
							<span><img src="../images/icons/transfer.gif" align="absmiddle"><a href="javascript:fGoto();" onclick="Transfer.goAdd('30','');CM.afterSubmit=Flow.listByAccount;CM.afterSubmit0=Tally.loadBoard;">转账</a></span>
						</li>

					</ul>

				</div>

			</div>
			<iframe src="" scrolling="no" style="display:none;position:absolute; z-index:1100;background-color:red; left:58px;top:60px; width: 480px;filter:alpha(opacity='0');">
			</iframe>
		</div>
		<div class="quick_href">
			<ul>
				<li><img src="../images/common/dot1.gif"/><a href="javascript:fGoto();" onclick="Tally.loadBoard();Flow.listByAccount('0');"><span>日常收支</span></a></li>
				<li><img src="../images/common/dot1.gif"/><a href="javascript:fGoto();" onclick="ImportAccount.goAdd();"><span>从caakee导入</span></a></li>
			</ul>
			<ul>
				<li><img src="../images/common/dot1.gif"/><a href="javascript:fGoto();" onclick="Tally.loadBoard();ImportAccount.doClear();"><span>清空所有</span></a></li>
			</ul>
		</div>
	</div>
</div>


<div class="box" id="tally_board">
	<div class="head">
		<div class="ul_wrapper">
			<ul>
				<li id="account" class="active"><a href="javascript:fGoto();" onclick="Tab.activeLi(this);Tally.activeBoard('account_board','category_board');Flow.listByAccount('1');">账户</a></li>
				<li id="category"><a href="javascript:fGoto();" onclick="Tab.activeLi(this);Tally.activeBoard('category_board','account_board');Flow.listByCategory();">收支类别</a></li>
			</ul>
		</div>
	</div>
	<div class="body account">

		<table cellpadding="0" cellspacing="0" class="account_table" id="account_board">
			<tr><td colspan="2" class="type"><img src="../images/st_icon.png">资金账户</td></tr><!-- 账户类型 -->

			<?php
			foreach($accountList as $account){
				?>
				<tr> <!-- 账户 -->
					<td width="50%">
						<img src="../images/common/dot1.gif"/>
						<a href="javascript:fGoto();" onclick="Tally.list('<?php echo $account["accountType"];?>','<?php echo $account["id"];?>');" title="<?php echo $account["name"];?>"><?php echo $account["name"];?></a>
					</td>
					<td class="balance" width="50%">
						<span class="<?php echo $account["currentValue"]>=0?'normal':'spec';?>"><?php echo $account["currentValue"];?></span>
					</td>
				</tr>
				<?php
			}
			?>

		</table>

		<ul class="cnt_list hidden list" id="category_board">

			<?php
			foreach($expenseFlowTypeList as $flowType){
				?>
				<li class="category_item">
					<input type="checkbox" value="<?php echo $flowType["id"];?>" onclick="Board.activeCategory(this,'<?php echo $flowType["flowType"];?>');Flow.searchByCategory();">

					<a href="javascript:fGoto();" onclick="Board.showCategory(this,'<?php echo $flowType["id"];?>');"><?php echo $flowType["name"];?></a>
				</li>
				<?php
			}
			?>



		</ul>


	</div>
</div>
<div class="clear"></div>